﻿// MT499




using Little.Soldier.SWIFT;
using Little.Soldier.SWIFT.Definition;
using System.Collections.Generic;
using System.ComponentModel;

namespace Little.Soldier.SWIFT.Messages.Category4
{
  public class MT499 : SwiftMessage
  {
    private static SwiftMessageDefinition MessageDefinition;
    private static SwiftTagDefinition U0002;
    private static SwiftTagSubItemDefinition U0003;
    private static SwiftTagDefinition U0004;
    private static SwiftTagSubItemDefinition U0005;
    private static SwiftTagDefinition U0006;

    [Description("Transaction Reference Number")]
    public Tag20 TransactionReferenceNumber_20
    {
      get
      {
        return new Tag20((SwiftElement) this, 0, (SwiftDefinitionElement) MT499.U0002);
      }
    }

    [Description("Transaction Reference Number")]
    public Tag20 Tag20_TransactionReferenceNumber
    {
      get
      {
        return this.TransactionReferenceNumber_20;
      }
    }

    [Description("Related Reference")]
    public Tag21 RelatedReference_21
    {
      get
      {
        return new Tag21((SwiftElement) this, 0, (SwiftDefinitionElement) MT499.U0004);
      }
    }

    [Description("Related Reference")]
    public Tag21 Tag21_RelatedReference
    {
      get
      {
        return this.RelatedReference_21;
      }
    }

    [Description("Narrative")]
    public Tag79[] Narrative_79
    {
      get
      {
        int index = -1;
        List<Tag79> list = new List<Tag79>();
        int count;
        do
        {
          ++index;
          Tag79 tag79 = new Tag79((SwiftElement) this, index, (SwiftDefinitionElement) MT499.U0006);
          count = this.ListTags((SwiftElement) tag79).Count;
          if (count > 0)
            list.Add(tag79);
        }
        while (count > 0);
        return list.ToArray();
      }
    }

    [Description("Narrative")]
    public Tag79[] Tag79_Narrative
    {
      get
      {
        return this.Narrative_79;
      }
    }

    public MT499()
      : base(true)
    {
    }

    public MT499(SwiftMessage message)
      : base(message)
    {
    }

    public Tag79 AddNarrative_79()
    {
      return new Tag79((SwiftElement) this, this.Narrative_79.Length, (SwiftDefinitionElement) MT499.U0006)
      {
        Value = string.Empty
      };
    }

    public void RemoveNarrative_79(Tag79 tag)
    {
      this.RemoveTag(tag.GetTag());
    }

    internal override SwiftMessageDefinition MsgDefinition()
    {
      return MT499.MessageDefinition;
    }

    protected override void InitSwiftMessageDefinition()
    {
      MT499.MessageDefinition = new SwiftMessageDefinition("MT499", "Free Format Message");
      MT499.U0002 = new SwiftTagDefinition("TransactionReferenceNumber_20", "Transaction Reference Number");
      MT499.U0002.TagName = ":20:";
      MT499.U0003 = new SwiftTagSubItemDefinition("Reference", "Reference");
      MT499.U0002.Elements.Add((SwiftDefinitionElement) MT499.U0003);
      MT499.MessageDefinition.Elements.Add((SwiftDefinitionElement) MT499.U0002);
      MT499.U0004 = new SwiftTagDefinition("RelatedReference_21", "Related Reference");
      MT499.U0004.TagName = ":21:";
      MT499.U0004.Mandatory = false;
      MT499.U0005 = new SwiftTagSubItemDefinition("Reference", "Reference");
      MT499.U0004.Elements.Add((SwiftDefinitionElement) MT499.U0005);
      MT499.MessageDefinition.Elements.Add((SwiftDefinitionElement) MT499.U0004);
      MT499.U0006 = new SwiftTagDefinition("Narrative_79", "Narrative");
      MT499.U0006.TagName = ":79:";
      MT499.U0006.Multiple = true;
      MT499.MessageDefinition.Elements.Add((SwiftDefinitionElement) MT499.U0006);
    }
  }
}
